VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Multi-String Trim Function [Added String Allocate Declares]

by Rde (54 Submissions)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Intermediate
Originally Published: Wed 31st August 2016
Date Added: Tue 9th February 2021
Rating: (1 Votes)

? Multi-String Trim Function ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ Multiple Unicode Strings The BSTR spec allows multiple strings and embedded NULLs. BSTRs are NULL-terminated. However, you can query a BSTR for its length rather than needing to scan it, so it can contain embedded NULL characters. Multiple Unicode strings are a string of NULL-delimited Unicode strings, terminated by two NULL characters. Multi-String Trim Functions APIs that can return Multi-strings require a special NULL-stripping function that does not terminate the string at the first occurrence of a NULL character. Common NULL trimming functions fail on Multi-strings. The Open File Dialog returns a Multi-string when a user selects more than one file, although the user may select only one file to open. Even when a Single-NULL terminated BSTR is returned you must still call a strip function designed to terminate the string at two NULL characters because the user could have selected many files to open. It is also necessary to append Double-NULLs to Multi-string input parameters. The Filter property of the Open File Dialog takes a Multi-string. Only one NULL character needs to be appended because the BSTR will always be Single-NULL terminated. ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ Accelerated TrimZZ Function TrimZZ handles Multi-strings. TrimZZ expects a NULL padded buffer receiving the character string, this ensures correct handling of Single-NULL terminated BStr's. However, it will process all** strings correctly and will return the full string if no Double-NULLs are encoutered within the allocated length of the passed string. ** Pre-filling the buffer with NULLs is required when you know you may get a Multi-string back from an API. This ensures correct handling if just a Single-NULL terminated string is returned. ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ The module now includes the following functions: StrAlloc FillZ TrimZ TrimZZ SplitZ SplitFileNames StrAlloc creates a new string to the specified length but it is not initialized with any characters. SplitFileNames is a specialized function for processing file names returned by the File Open Dialog. SplitZ works just like VB's Split function, but unlike Split it will not append empty strings to the array. The module now includes the following API declares: AllocStrB AllocStrSp AllocStrVpSp RTrimZSp RTrimZVpSp

Rate Multi-String Trim Function [Added String Allocate Declares]

Download Multi-String Trim Function [Added String Allocate Declares]

Download Multi-String Trim Function [Added String Allocate Declares] (4 KB)

Multi-String Trim Function [Added String Allocate Declares] Comments

No comments have been posted about Multi-String Trim Function [Added String Allocate Declares]. Why not be the first to post a comment about Multi-String Trim Function [Added String Allocate Declares].

Post your comment

Subject:
Message:
0/1000 characters